import { _decorator, Component, Node, director, Scene, tween, Sprite, } from 'cc';
import AssetsMgr from './Model/AssetsMgr';
import { LoadingProgress } from './UI/Component/LoadingProgress';
const { ccclass, property } = _decorator;
@ccclass('Start')
export class Start extends Component {

    @property(Sprite)
    loadingSprite: Sprite = null;
    @property(LoadingProgress)
    loadingProgress: LoadingProgress = null;

    async onLoad() {
        this.loadingProgress.init();

        let tw = tween(this.loadingProgress).to(10, { progress: 1 }).start();
        await AssetsMgr.Init();

        let rs = null;
        let progress = new Promise((resolve) => {
            rs = resolve;
        });
        tw.stop();
        tween(this.loadingProgress).to(1, { progress: 1 }).call(rs).start();

        await progress;

        // SoundManager.Instance.init();

        director.loadScene("gameScene");
        // director.loadScene("testScene");
        // Global.EnableMapSpawn = false;

    }
}


